
package T4.EjemplosDelSwing.ejemplosgui;

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

class Frame5 extends JFrame {

    public Frame5() {
        setTitle("Hola!!!");
        setSize(500, 400);
        addWindowListener(new manejador5());
        Container contentpane = getContentPane();
        JPanel panel = new JPanel();
        panel.setLayout(null);
        JButton boton = new JButton();
        boton.setBounds(300, 200, 50, 90);
        panel.add(boton);
        contentpane.add(panel);
        panel.setBackground(Color.red);
    }
}

class manejador5 extends WindowAdapter {

    public void windowClosing(WindowEvent e) {
        System.out.println("sali");
        System.exit(0);
    }
}

public class Ejemplo5 {

    public static void main(String[] args) {
        JFrame frame = new Frame5();
        frame.setVisible(true);
    }
}
